package com.yunli.mall.common.schema;

import com.github.pagehelper.PageInfo;
import lombok.Data;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * @author wangyue
 * @date 2020-05-27 21:42
 */
@Data
public class ResponsePageData<T> implements Serializable {

    /**
     * 页码，从1开始
     */
    private int pageNum;

    /**
     * 页面大小
     */
    private int pageSize;

    /**
     * 总数
     */
    private long total;

    /**
     * 总页数
     */
    private int pages;

    /**
     *
     */
    private List<T> data = new ArrayList<>();

    public ResponsePageData() {
    }

    public ResponsePageData(PageInfo<T> pageInfo) {
        this.pageNum = pageInfo.getPageNum();
        this.pageSize = pageInfo.getPageSize();
        this.total = pageInfo.getTotal();
        this.pages = pageInfo.getPages();
        this.data = pageInfo.getList();
    }

}
